class Solution:
    def gameOfLife(self, board: list) -> None:
        max_length, max_height = len(board[0]) - 1, len(board) - 1
        for i in range(max_height + 1):
            for j in range(max_length + 1):
                live_count = (board[i - 1][j - 1] > 0) if i > 0 and j > 0 else 0
                live_count += (board[i - 1][j] > 0) if i > 0 else 0
                live_count += (board[i - 1][j + 1] > 0) if i > 0 and j < max_length else 0
                live_count += (board[i][j - 1] > 0) if j > 0 else 0
                live_count += (board[i][j + 1] > 0) if j < max_length else 0
                live_count += (board[i + 1][j - 1] > 0) if i < max_height and j > 0 else 0
                live_count += (board[i + 1][j] > 0) if i < max_height else 0
                live_count += (board[i + 1][j + 1] > 0) if i < max_height and j < max_length else 0
                if board[i][j] == 1 and (live_count > 3 or live_count < 2):
                    board[i][j] = 2
                if board[i][j] == 0 and live_count == 3:
                    board[i][j] = -1
        for i in range(max_height + 1):
            for j in range(max_length + 1):
                if board[i][j] == -1:
                    board[i][j] = 1
                elif board[i][j] == 2:
                    board[i][j] = 0


a = Solution()
b = [[0, 1, 0],
     [0, 0, 1],
     [1, 1, 1],
     [0, 0, 0]]
a.gameOfLife(b)
print(b)
